package com.school.controller.permission;

import com.school.service.PermissionService;
import com.school.service.RoleService;
import com.school.service.impl.PermissionServiceImpl;
import com.school.service.impl.RoleServiceImpl;
import com.school.util.ResponseJsonUtil;
import com.school.vo.R;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/permission/delete")
public class DeleteController extends HttpServlet {
    PermissionService service = new PermissionServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 插入 数据
        String id = req.getParameter("id");// ID

        if (id != null){
            Integer i = Integer.valueOf(id);
            // 调用Service中的方法
            service.delete(i);
            ResponseJsonUtil.write(resp, R.ok());
        }else {
            // json格式传递到前端
            ResponseJsonUtil.write(resp, R.err());
        }
    }
}
